package ua.lviv.franko.triangulation.SaveStructures;

public class Node implements Cloneable, Comparable<Node> {

	public double	x;
	public double	y;
	public int		Number;
	public boolean	IsOnBoundery;
	public boolean	IsDirihlet;
	public boolean	IsActive;
	public double	dirVal;

	public Node() {
		this.IsDirihlet = false;
	}

	public Node(double x, double y, boolean IsOnBoundery, int Number) {
		this.x = x;
		this.y = y;
		this.Number = Number;
		this.IsOnBoundery = IsOnBoundery;
		this.IsDirihlet = false;
	}

	@Override
	public boolean equals(Object obj) {// дуже обережно з цим методом так як він
										// перевіряє номер а не дійсно точку ...
		try {
			Node tmp = (Node) obj;
			// return ( (Math.abs(tmp.x-x)<0.000000001) &&
			// (Math.abs(tmp.y-y)<0.0000001) );
			return (tmp.Number == this.Number);
		} catch (Exception e) {
			return false;
		}
	}

	@Override
	public int hashCode() {
		int hash = 7;
		hash = 97 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
		hash = 97 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
		hash = 97 * hash + (this.IsOnBoundery ? 1 : 0);
		return hash;
	}

	public Node myClone() {
		return new Node(x, y, IsOnBoundery, Number);
	}

	@Override
	public String toString() {

		return x + "\t" + y;
	}

	@Override
	protected Object clone() {
		return new Node(x, y, IsOnBoundery, Number);
	}

	@Override
	public int compareTo(Node o) {
		return this.Number - o.Number;
	}

}
